#ifndef _st7567_H
#define _st7567_H
#include "aky_define.h"

#define RESET_PORT GPIO3 //
#define RESET_PIN Pin_4
#define RESET_H   (LINK2(CHAR_P,RESET_PORT) |= RESET_PIN)
#define RESET_L  (LINK2(CHAR_P,RESET_PORT) &= ~(RESET_PIN))
#define RESET_PROT_REG  LINK3(CHAR_P,RESET_PORT,CHAR_M)//PxM
#define RESET_UP_REG  LINK3(CHAR_P,RESET_PORT,CHAR_UR)

#define RS_PORT GPIO3 //
#define RS_PIN Pin_5
#define RS_H   (LINK2(CHAR_P,RS_PORT) |= RS_PIN)
#define RS_L  (LINK2(CHAR_P,RS_PORT) &= ~(RS_PIN))
#define RS_PROT_REG  LINK3(CHAR_P,RS_PORT,CHAR_M)//PxM
#define RS_UP_REG  LINK3(CHAR_P,RS_PORT,CHAR_UR)

#define CS_PORT GPIO3 //
#define CS_PIN Pin_3
#define CS_H   (LINK2(CHAR_P,CS_PORT) |= CS_PIN)
#define CS_L  (LINK2(CHAR_P,CS_PORT) &= ~(CS_PIN))
#define CS_PROT_REG  LINK3(CHAR_P,CS_PORT,CHAR_M)//PxM
#define CS_UP_REG  LINK3(CHAR_P,CS_PORT,CHAR_UR)

#define WR_PORT GPIO3 //
#define WR_PIN Pin_6
#define WR_H   (LINK2(CHAR_P,WR_PORT) |= WR_PIN)
#define WR_L  (LINK2(CHAR_P,WR_PORT) &= ~(WR_PIN))
#define WR_PROT_REG  LINK3(CHAR_P,WR_PORT,CHAR_M)//PxM
#define WR_UP_REG  LINK3(CHAR_P,WR_PORT,CHAR_UR)


#define RD_PORT GPIO3 //
#define RD_PIN Pin_7
#define RD_H   (LINK2(CHAR_P,RD_PORT) |= RD_PIN)
#define RD_L  (LINK2(CHAR_P,RD_PORT) &= ~(RD_PIN))
#define RD_PROT_REG  LINK3(CHAR_P,RD_PORT,CHAR_M)//PxM
#define RD_UP_REG  LINK3(CHAR_P,RD_PORT,CHAR_UR)

#define SCL_PORT GPIO4 //
#define SCL_PIN Pin_6
#define SCL_H   (LINK2(CHAR_P,SCL_PORT) |= SCL_PIN)
#define SCL_L  (LINK2(CHAR_P,SCL_PORT) &= ~(SCL_PIN))
#define SCL_PROT_REG  LINK3(CHAR_P,SCL_PORT,CHAR_M)//PxM
#define SCL_UP_REG  LINK3(CHAR_P,SCL_PORT,CHAR_UR)

#define SDA_PORT GPIO4 //
#define SDA_PIN Pin_7
#define SDA_H   (LINK2(CHAR_P,SDA_PORT) |= SDA_PIN)
#define SDA_L  (LINK2(CHAR_P,SDA_PORT) &= ~(SDA_PIN))
#define SDA_PROT_REG  LINK3(CHAR_P,SDA_PORT,CHAR_M)//PxM
#define SDA_UP_REG  LINK3(CHAR_P,SDA_PORT,CHAR_UR)

#define LCD_BL_PORT GPIO5 //背光
#define LCD_BL_PIN Pin_1
#define LCD_BL_ON   (LINK2(CHAR_P,LCD_BL_PORT) |= LCD_BL_PIN)
#define LCD_BL_OFF  (LINK2(CHAR_P,LCD_BL_PORT) &= ~(LCD_BL_PIN))
#define LCD_BL_PROT_REG  LINK3(CHAR_P,LCD_BL_PORT,CHAR_M)//PxM
#define LCD_BL_UP_REG  LINK3(CHAR_P,LCD_BL_PORT,CHAR_UR)

#define LCD_POWER_PORT GPIO5 //电源
#define LCD_POWER_PIN Pin_0
#define LCD_POWER_ON   (LINK2(CHAR_P,LCD_POWER_PORT) &= ~(LCD_POWER_PIN))
#define LCD_POWER_OFF  (LINK2(CHAR_P,LCD_POWER_PORT) |= LCD_POWER_PIN) 
#define LCD_POWER_PROT_REG  LINK3(CHAR_P,LCD_POWER_PORT,CHAR_M)//PxM
#define LCD_POWER_UP_REG  LINK3(CHAR_P,LCD_POWER_PORT,CHAR_UR)

void initial_lcd(void);
void transfer_command(int data1);
void transfer_data(int data1);
void st7567_init(void);

#endif